/*********************************************************
          File Name:friend.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 15 Feb 2016 08:49:37 PM CST
**********************************************************/

#include <iostream>

template<typename T>
void disp(const T &x)
{
    std::cout << x.show() << std::endl;
}

class X
{
    private:
        int v;
        int show() const
        {
            return v;
        }
    public:
        X(): v(309){}
        ~X(){}

        template<typename T> friend void disp(const T &x);
};

class Y
{
    private:
        int x;

    public:
        Y(): x(11){}
        ~Y() {}

        int show() const
        {
            return x;
        }
};

int main()
{
    X x;
    Y y;
    disp(x);
    disp(y);
    return 0;
}
